Skip to content

CMR-11630: As a CMR operator I want to add a token and user deny list to CMR access control. - #2539

Merged
daniel-zamora merged 6 commits into
masterfrom
CMR-11630
Nov 20, 2026
Merged

daniel-zamora merged 6 commits into
masterfrom
CMR-11630

Conversation

@daniel-zamora

@daniel-zamora daniel-zamora commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Overview

What is the objective?

CMR has no way to revoke a specific token or user. Removing ACLs still leaves registered access, and tokens revoked in EDL keep working while JWTs are verified locally. This adds a CMR deny list for tokens and users.

What are the changes?

  • Deny list stored in a Redis hash, with entries keyed by a token's SHA-256 hash or a user id.
  • Search, ingest and access-control return 401 for requests whose token or user is listed. The system token is never blocked.
  • Each instance reloads the list every 30 seconds (CMR_TOKEN_DENYLIST_REFRESH_SECONDS) and keeps its last copy if Redis is unavailable. Before an instance's first load, requests wait up to 500 ms for it and then go unchecked.
  • A token's user is only looked up when the list has user entries; legacy tokens are matched by hash only. If the lookup fails, the request fails with that error. Access-control gets a token to user id cache for this.
  • User ids match case-insensitively.
  • Access-control /current-sids also rejects listed tokens.
  • A listed user's email and NRT subscriptions stop sending notifications.
  • New access-control endpoints GET /token-denylist and PUT/DELETE /token-denylist/{tokens|users}/:id, requiring system INGEST_MANAGEMENT_ACL. Changes also need a token that passes the write token check. reason is optional, at most 500 characters. Documented in the access-control API docs.
  • A JWT's hash covers its signed header and payload, so every encoding of a token has the same hash. Any other token is hashed whole, without a Bearer prefix. The API docs give the commands.
  • Ingest's "Successfully ingested" log line adds user, when already known without extra lookups, and token_hash.
  • token_hash is also logged on ingest's "Deleting" lines and on search's "Found" and granule timeline lines. The system token is never hashed into logs.

What areas of the application does this impact?

  • transmit-lib
  • common-app-lib
  • search-app
  • ingest-app
  • access-control-app

Required Checklist

  • New and existing unit and int tests pass locally and remotely
  • clj-kondo has been run locally and all errors in changed files are corrected
  • I have commented my code, particularly in hard-to-understand areas
  • I have made changes to the documentation (if necessary)
  • My changes generate no new warnings

Additional Checklist

  • I have removed unnecessary/dead code and imports in files I have changed
  • I have cleaned up integration tests by doing one or more of the following:
    • migrated any are2 tests to are3 in files I have changed
    • de-duped, consolidated, removed dead int tests
    • transformed applicable int tests into unit tests
    • reduced number of system state resets by updating fixtures. Ex) (use-fixtures :each (ingest/reset-fixture {})) to be :once instead of :each

@daniel-zamora daniel-zamora changed the title CMR-11630: add token and user deny list CMR-11630: As a CMR operator I want to add a token and user deny list to CMR access control. Nov 14, 2026
(defn create-snapshot-cache
"Creates the cache holding this instance's snapshot of the deny list."
[]
(mem-cache/create-in-memory-cache))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may not remember how the cache code works, but is this ignored by the code as the store method uses the Redis cache system?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redis holds the list, the instances keep a snapshot that updates via polling

@codecov-commenter

codecov-commenter commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.67790% with 113 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.54%. Comparing base (b7208d8) to head (7d27180).

Files with missing lines Patch % Lines
transmit-lib/src/cmr/transmit/token_denylist.clj 69.16% 24 Missing and 13 partials ⚠️
...-app-lib/src/cmr/common_app/api/token_denylist.clj 63.73% 25 Missing and 8 partials ⚠️
ingest-app/src/cmr/ingest/api/core.clj 23.80% 11 Missing and 5 partials ⚠️
...pp/src/cmr/access_control/services/acl_service.clj 0.00% 3 Missing ⚠️
ingest-app/src/cmr/ingest/api/granules.clj 0.00% 3 Missing ⚠️
ingest-app/src/cmr/ingest/api/subscriptions.clj 0.00% 3 Missing ⚠️
...ingest/services/nrt_subscription/subscriptions.clj 0.00% 0 Missing and 3 partials ⚠️
search-app/src/cmr/search/api/concepts_search.clj 0.00% 3 Missing ⚠️
search-app/src/cmr/search/api/core.clj 0.00% 3 Missing ⚠️
...p/src/cmr/ingest/services/subscriptions_helper.clj 0.00% 2 Missing ⚠️
... and 6 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2539      +/-   ##
==========================================
+ Coverage   54.52%   54.54%   +0.02%     
==========================================
  Files        1047     1049       +2     
  Lines       73638    73886     +248     
  Branches     2417     2445      +28     
==========================================
+ Hits        40148    40302     +154     
- Misses      31205    31272      +67     
- Partials     2285     2312      +27     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jaortega527 jaortega527 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the changes manually and using LLM. No findings.

@daniel-zamora
daniel-zamora merged commit 59a1dce into master Nov 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants